//
//  ImageAndVideoSaveTool.m
//  OnionHome
//
//  Created by fengjie on 2019/10/11.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "ImageAndVideoSaveTool.h"

@implementation ImageAndVideoSaveTool

#pragma mark ---保存指定图片到沙盒中
+(void)saveImageDocuments:(UIImage *)image imageName:(NSString *)imageName{
 
    UIImage * imageSave = image;
    NSString * path_sandox = NSHomeDirectory();
    DLog(@"%@",path_sandox);
//    设置一个图片的存储路径
    NSString * imagePath = [NSString stringWithFormat:@"%@/Documents/%@.png",path_sandox,imageName];
//    [path_sandox stringByAppendingString:@"/Documents/%@.png",imagename];
//    把图片直接保存到指定的路径
    [UIImagePNGRepresentation(imageSave) writeToFile:imagePath atomically:YES];
}
#pragma mark --根据图片名称获取沙盒中图片
+(UIImage *)getDocumentImageimageName:(NSString *)imageName{
//    读取沙盒路径图片
    NSString *aPath3=[NSString stringWithFormat:@"%@/Documents/%@.png",NSHomeDirectory(),imageName];
//    拿到沙盒路径图片
    UIImage *img=[[UIImage alloc]initWithContentsOfFile:aPath3];
//    返回该图片
    return img;
}
#pragma mark --获取唯一  字符串 用来给图片取名字
+ (NSString*)get_ONLYID{

    CFUUIDRef uuidRef =CFUUIDCreate(NULL);

    CFStringRef uuidStringRef =CFUUIDCreateString(NULL, uuidRef);

    NSString *uniqueId = (__bridge NSString *)(uuidStringRef);

    return uniqueId;

}
@end
